#pragma once

#include <QDebug>
#include <QObject>
#include <QRect>
#include <QString>

namespace ukuiwaylandclient
{
class UkuiWindow;

QDebug operator<<(QDebug dbg, const UkuiWindow *window);

// This class save the information of a window
class UkuiWindow : public QObject
{
    Q_OBJECT
public:
    UkuiWindow(const QString &uuid, uint32_t id = 0);
    ~UkuiWindow() = default;

    QString uuid() const;
    uint32_t objectId() const;

    void setTitle(const QString &title);
    QString title() const;

    void setAppId(const QString &appId);
    QString appId() const;

    void setPid(int32_t pid);
    int32_t pid() const;

    void setGeometry(const QRect &geometry);
    QRect geometry() const;

    void setThemedIconName(const QString &name);
    QString themedIconName() const;

    void setResourceName(const QString &name);
    QString resourceName() const;

    void setParentWindow(UkuiWindow *parent);
    UkuiWindow *parentWindow() const;

    void setVirtualDesktop(const QString &virtualDesktopId);
    QString virtualDesktop() const;

    void setState(uint32_t state);

    bool isActive() const;
    bool isMinimized() const;
    bool isMaximized() const;
    bool isFullScreen() const;
    bool isKeepAbove() const;
    bool isKeepBelow() const;
    bool isOnAllDesktops() const;
    bool isDemandsAttention() const;
    bool isCloseable() const;
    bool isMinimizable() const;
    bool isMaximizable() const;
    bool isFullScreenable() const;
    bool isShadeable() const;
    bool isShaded() const;
    bool isMovable() const;
    bool isResizable() const;
    bool isVirtualDesktopChangeable() const;
    bool isAcceptFocus() const;
    bool isSkipTaskbar() const;
    bool isSkipSwitcher() const;
    bool isModality() const;

    friend QDebug operator<<(QDebug dbg, const UkuiWindow *window);

Q_SIGNALS:
    void titleChanged(const QString &title);
    void appIdChanged(const QString &appId);
    void pidChanged(int pid);
    void geometryChanged(const QRect &geometry);
    void themedIconNameChanged(const QString &name);
    void resourceNameChanged(const QString &name);
    void parentWindowChanged(UkuiWindow *parent);
    void virtualDesktopChanged(const QString &virtualDesktopId);
    void stateChanged(int state);

private:
    uint32_t m_objectId;

    QString m_uuid;
    QString m_title;
    QString m_appId;
    int m_pid;
    QRect m_geometry;
    int m_state;
    QString m_themedIconName;
    QString m_resourceName;
    UkuiWindow *m_parent = nullptr;
    QString m_virtualDesktopId;
};

}